import { Cookies, LocalStorage } from "quasar";

const config = {
  cookieExpires: 1
};

export default {
  getToken() {
    const token = Cookies.get("token");
    return token ?? "";
  },
  setToken(token: string) {
    Cookies.set("token", token, {
      expires: config.cookieExpires,
      sameSite: "Lax"
    });
  },
  getRefreshToken() {
    const refreshToken = Cookies.get("refreshToken");
    return refreshToken ?? "";
  },
  setRefreshToken(token: string) {
    Cookies.set("refreshToken", token, {
      expires: config.cookieExpires + 2,
      sameSite: "Lax"
    });
  },
  setLang(lang: string) {
    LocalStorage.set("language", lang);
  },
  getLang() {
    return LocalStorage.getItem("language");
  },
  setTheme(theme: string) {
    LocalStorage.set("theme", theme);
  },
  getTheme() {
    return LocalStorage.getItem("theme") as string;
  },
  setCurrentRole(id: number) {
    LocalStorage.set("currentRole", id);
  },
  getCurrentRole() {
    return LocalStorage.getItem("currentRole");
  }
};
